package API.MathAPI.Test;
import java.util.Scanner;

//本代码使用了Math API，并根据非质数因数的规律简化了算法
public class IsPrimeNumber {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        if(isPrime(num)){
            System.out.println(num + "是质数");
        } else {
            System.out.println(num + "不是质数");
        }
    }

    //判断传入的数字是否为质数
    public static boolean isPrime(int num) {
        for (int i = 2; i <= Math.sqrt(num); i++) {
            if(num % i == 0) {
                return false;
            }
        }
        return true;
    }
}
